# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=python-mediafire
_pkgname="${pkgname#python-}"
pkgver=0.6.1
pkgrel=1
pkgdesc='Python implementation of MediaFire Core API client'
arch=('any')
url='https://pypi.org/project/mediafire/'
license=('BSD')
depends=(
  'python'
  'python-requests'
  'python-requests-toolbelt'
  'python-six'
)
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
source=("$pkgname-$pkgver.tar.gz::https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('738bff67f506109eba9ef6380f2e9ba22771ce71c6ab8976dd4e8c732ed1ab1fe430a700107e835b2b049c80a064c9d46242b9d22f53b0cd613bbd344d20fa39')
b2sums=('f54637a8a7598395615db9b677eee3333fb1012d138ae528f19b93446e8095511698fac71cc4f1b6052b54fa1a204aee3b1c5e64094b6a296b5cd3ff64f3f15a')

build() {
  cd "$_pkgname-$pkgver"

  python -m build --wheel --no-isolation
}

package() {
  cd "$_pkgname-$pkgver"

  python -m installer --destdir="$pkgdir" dist/*.whl

  # symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir/usr/share/licenses/$pkgname"
  ln -s "$site_packages/${pkgname#python-}-$pkgver.dist-info/LICENSE.txt" \
    "$pkgdir/usr/share/licenses/$pkgname/LICENSE.txt"
}
